#include"TcpServer.hpp"
#include"Common.hpp"
#include<memory>
#include"Log.hpp"
#include"Service.hpp"
#include"Socket.hpp"
#include"NetCal.hpp"
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << "serverport" << std::endl;
        exit(-1);
    }
    uint16_t port = std::stoi(argv[1]);

    NetCal netcal;
    Service service_func(std::bind(&NetCal::CalWork,&netcal,std::placeholders::_1));
    
    server_IO_t func = std::bind(&Service::IOExcute,&service_func,std::placeholders::_1,std::placeholders::_2);
    std::unique_ptr<TcpServer> service = std::make_unique<TcpServer>(func,port);

    service->Start();
    return 0;
}